package mrh.niubi.librarysystem.mapper;

import mrh.niubi.librarysystem.pojo.Avatar;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AvatarMapper {
    @Insert("insert into avatar(type, size, url, md5, count) values(#{type},#{size},#{url},#{md5},#{count})")
    public void save(Avatar avatar);

    @Select("select * from avatar where md5 = #{md5}")
    public Avatar selectByMd5(String md5);

    @Select("select * from avatar where url = #{url}")
    public Avatar selectByUrl(String url);

    @Delete("delete from avatar where url = #{url}")
    int deleteByUrl(String url);

    @Update("update avatar set count = count -1 where url = #{url}")
    int subCount(String url);

    @Update("update avatar set count = count +1 where url = #{url}")
    int addCount(String url);

}
